package appapi.service.impl;

import appapi.Request.AlarmledgerReq;
import appapi.Vo.record.GetAlarmPageVo;
import appapi.dao.AlarmledgerMapper;
import appapi.dao.OrganizationMapper;
import appapi.dao.StaffMapper;
import appapi.dto.AlarmLedgerModel;
import appapi.dto.GetAlarmPageDto;
import appapi.entity.Zhongjiao.AlarmledgerEntity;
import appapi.entity.basic.UserInfo;
import appapi.service.IAlarmledgerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 告警台账
 *
 * @author lc
 * @version 1.0
 * @date 2023-05-12 18:19:10
 */
@Component
public class AlarmledgerServiceImpl implements IAlarmledgerService {

    @Resource
    AlarmledgerMapper alarmledgerMapper;
    @Resource
    StaffMapper staffMapper;
    @Resource
    OrganizationMapper organizationMapper;

    @Override
    public PageInfo<GetAlarmPageVo> getPage(UserInfo userInfo, GetAlarmPageDto dto) {

        if (dto.getOrgaPathIds()==null) {
            //拿到人员信息
            Map<String, Object> staffDto = staffMapper.selectStaffDetail(userInfo.getUserid());
            String orgaPathIds = staffDto.get("orgaPathIds").toString();
            dto.setOrgaPathIds(orgaPathIds);
        }
        PageHelper.startPage(dto.getCurrPage(), dto.getPageSize());

        List<GetAlarmPageVo> list = alarmledgerMapper.selectList(dto);

        PageInfo pageInfo = new PageInfo(list, dto.getPageSize());

        return pageInfo;
    }

    @Override
    public List<AlarmledgerEntity> list(AlarmledgerReq alarmledgerReq) {
        return null;
    }

    @Override
    public AlarmledgerEntity detail(Long alarmId, Integer tenantId) {
        return null;
    }

    @Override
    public int count(AlarmledgerEntity alarmledgerEntity) {
        return 0;
    }

    @Override
    public int insert(AlarmledgerEntity alarmledgerEntity) {
        return 0;
    }

    @Override
    public int update(AlarmledgerEntity alarmledgerEntity) {
        return 0;
    }

    @Override
    public int delete(Long alarmId, Integer tenantId) {
        return 0;
    }

    @Override
    public List<AlarmLedgerModel> getList(GetAlarmPageDto dto) {
        List<AlarmLedgerModel> list = alarmledgerMapper.queryList(dto);
        return list;
    }

}
